﻿//03.Write a program to check if in a given expression the brackets are put correctly.
//Example of correct expression: ((a+b)/5-d).
//Example of incorrect expression: )(a+b)).

using System;

namespace CheckBrackets
{
    class CheckBrackets
    {
        static void Main()
        {
            Console.Write("Enter an expression: ");
            string expression = Console.ReadLine();

            int bracketCounter = 0;

            for (int i = 0; i < expression.Length; i++)
            {
                if (expression[i] == '(' || expression[i] == '{' || expression[i] == '[')
                {
                    bracketCounter++;
                }
                else if (expression[i] == ')' || expression[i] == '}' || expression[i] == ']')
                {
                    bracketCounter--;
                }
            }

            if (bracketCounter == 0)
            {
                Console.WriteLine("The expression is correct.");
            }
            else
            {
                Console.WriteLine("The expression is not correct.");
            }
        }
    }
}
